import { http } from '@/utils/http';
import type { Plan } from './index.d';

export { Plan };

/** 获取部分图书 */
export const getPlanListApi = (data: Plan.GetParams) => {
	return http({
		url: `/api/plan/teacher/list`,
		method: 'GET',
		data,
	});
};

/** 获取当前教师的班级列表 */
export const getClassListApi = () => {
	return http({
		url: `/api/teacher/class`,
		method: 'GET',
	});
};

/** 添加计划 */
export const addPlanApi = (data: Plan.AddParams) => {
	return http({
		url: `/api/plan/teacher/create`,
		method: 'POST',
		data,
	});
};
/** 编辑计划 */
export const editPlanApi = (data: Plan.EditParams) => {
	return http({
		url: `/api/plan/teacher/modify/${data.id}`,
		method: 'POST',
		data,
	});
};
/** 删除计划 */
export const delPlanApi = (id: number) => {
	return http({
		url: `/api/plan/teacher/${id}`,
		method: 'DELETE',
	});
};
/** 添加计划 */
export const getPlanRecordList = (data: Plan.RecordListParams) => {
	return http({
		url: `/api/plan/teacher/class_plan/${data.id}`,
		method: 'GET',
		data: { type: data.type, page: data.page },
	});
};
/** 获取计划详情 */
export const getPlanInfoDetailApi = (PlanId: number) => {
	return http({
		url: `/api/plan/teacher/plan/${PlanId}`,
		method: 'GET',
	});
};
/** 获取计划详情 */
export const getPlanDetailBookListApi = (PlanId: number) => {
	return http({
		url: `/api/plan/teacher/plan_book/${PlanId}`,
		method: 'GET',
		data: {
			page: 1,
			page_size: 20,
		},
	});
};

/**  获取班级排行接口【平台/班级计划】 */
export const getPlanClassRecord = (query: Plan.ClassRecordParams) => {
	return http<Plan.ClassRecordData>({
		url: `/api/plan/class_top/${query.id}`,
		method: 'GET',
		query,
	});
};

/**  获取学生排行接口【平台/班级计划】 */
export const getPlanParticiRecord = (query: Plan.ParticiParams) => {
	return http<Plan.ParticiData>({
		url: `/api/plan/student_top/${query.id}`,
		method: 'GET',
		query,
	});
};
/**  获取学生阅读详情 */
export const getStudentReadInfoAPI = (query: Plan.StudentReadParams) => {
	return http({
		url: `/api/plan/student/study`,
		method: 'GET',
		query,
	});
};

/**  获取计划 -- 年级 */
export const getPlanGradeList = (sid: number) => {
	return http<Plan.GradeData[]>({
		url: `/api/school_grade`,
		method: 'GET',
		data: { school_id: sid },
	});
};
/**  获取平台计划列表 */
export const getPlantformList = (query: Plan.ListParams) => {
	return http<Plan.ListData[]>({
		url: `/api/plan/teacher/plan_list?grade=${query.grade}`,
		method: 'GET',
	});
};

/** 首页计划banner */
export const getTopBannerApi = () => {
	return http({
		url: `/api/banner/banner_list`,
		method: 'POST',
	});
};
